<!-- body -->
<div class="body-cont" id="testdelete">
    <div class="col-9 row">
        <div class="mod" id="edit_service">
            <div class="mod-bread">
                <a href="index.php">Trang chủ </a> >
                <a href="index.php?r=service/show">Dịch vụ</a> >
                <a href="#">Tư vấn</a>
            </div>
            <div class="pro-tit line-dot" style="height = 180px;" >
            <p> <?php echo $model->time_create;?></p>
            <div id="test">
                <h1> <?php echo $model->name;?>
                <div class="clr"></div>
                </h1>
            </div>
            <?php
            if(Yii::app()->user->id != $model->user_id){
            ?>
            <span class="button-se">
                <a href="<?php
                    if(isset(Yii::app()->user->id)){
                            echo 'index.php?r=service/bid&id='.$model->id;
                    }else{
                            echo 'index.php?r=user/login';
                    }
                ?>"> <!--bid-->
                <input type="button" value="Tham gia dịch vụ"/>
                </a>
            </span>
            <?php }?>
            </div>
            <div class="pro-stat">
                <p>Số người tham gia:</p>
                <b><?php echo Bid_Service::countBid($model->id) . " người"; ?></b><br />
                Loại dịch vụ:
                <b><?php echo TypeJob::getname($model->servicetype); ?> </b><br />
                Khoảng tài chính:
                <b><?php echo number_format($model->money,0, ',', '.')." VNĐ";?></b>
                <p>
                    <span>Thời gian thực hiện:
                    <b><?php echo $model->completiondate." ngày";?></b>
                    </span>
                </p>
            </div>
            <div class="pro-detail">
                <div class="descr">
                    <h1>Mô tả:</h1>
                    <p id="content_mota" style="display: block;">
                                        <?php echo $model->description; ?>
                    </p>
                    <?php $form=$this->beginWidget('CActiveForm', array(
                                            'id'=>"edt_mota",
                                            'enableAjaxValidation'=>false,
                                            'htmlOptions'=>array(
                                                'style'=>"display: none;",
                                                'name'=>"mota",
                                                'autocomplete'=>'off',
                                               'onsubmit'=>"return false;",
                                                'onkeypress'=>" if (event.keyCode == 13) {
                                                  ".CHtml::ajax(array(
                                                    'url'=>CController::createUrl('create/update'),
                                                    'type'=>'POST',
                                                    'update'=>'#content_mota', // update vào thẻ có id = content_mota
                                                    'data'=>"js:$('#edt_mota').serialize()",
                                                    ))."
                                                } ",
                                                ),
                                        ));
                    ?>
                    <?php echo $form->hiddenField($model, 'id', array('value'=>$model->id));?>
                    <?php //echo $form->hiddenField($model, 'servicetype', array('value'=>$model->servicetype));?>
                    <?php //echo $form->hiddenField($model, 'money', array('value'=>$model->money));?>
                    <?php //echo $form->hiddenField($model, 'contact', array('value'=>$model->contact));?>
                    <?php //echo $form->hiddenField($model, 'completiondate', array('value'=>$model->completiondate));?>
                    <?php //echo $form->hiddenField($model, 'time_create', array('value'=>$model->time_create));?>
                    <?php //echo $form->hiddenField($model, 'user_id', array('value'=>$model->user_id));?>
                    <?php // echo $form->hiddenField($model, 'image', array('value'=>$model->image));?>
                    <?php echo $form->textArea($model, 'description', array('rows'=>10, 'cols'=>40));?>
                    <?php //echo $form->textField($model,'name', array('value'=>$model->name));?>
                    <?php echo CHtml::link('Save',"javascript:void(0);",
                                array(
                                    'id'=>"button_dang",
                                    'onclick'=>'{ '.Chtml::ajax(array(
                                        'url'=>CController::createUrl('create/update'),
                                        'type'=>"POST",
                                        'update'=>"#content_mota",
                                        'data'=>"js:$('#edt_mota').serialize()"
                                        )).'}',

                    ));
                    ?>
                    <?php $this->endWidget();?>
                    <?php if ($model->user_id == Yii::app()->user->id){?>
                    <a href="#" id="button_edit">Edit</a>
                    <?php }?>
                </div><!--end derc-->
                <div class="creator">
                    <p>
                        <img src="<?php echo Yii::app()->request->baseUrl.'/frontend/data/file/'.$model->image;?>" title="abc" alt="abc" width="215px" height="169px" style="border-top-width: 20px; margin-top: 0px; margin-right: 0px;"/>
                    </p>
                    <h4>Liên hệ: </h4><br />
                    <b><?php echo $model->contact;?></b><br />
                    <h4>Dịch vụ của:
                        <a href="<?php echo 'index.php?r=service/show/user&id='.$model->user_id; ?>" >
                        <?php echo User::getName($model->user_id);?>
                        </a>
                    </h4>
                    <h4> Tags :  
                    <?php echo implode(', ', $model->tagLinks); ?>
                    </h4>
                    <?php if($model->user_id == Yii::app()->user->id) {?>
          <!--Nhãn update-->
                    <a href="index.php?r=service/create/updateAll&id=<?php echo $model->id;?>">
                        <input type= "button" value="Sửa dịch vụ này"/>
                    </a>
          <!--NHÃN DELETE-->
                    <?php
                        $form=$this->beginWidget('CActiveForm', array(
                                        'enableAjaxValidation'=>true,
                        ));
                    ?>
                    <?php
                        echo CHtml::ajaxSubmitButton('Xóa dịch vụ này',
                                                array('create/delete','delete'=>$model->id),
                                                array('success'=>'function(data){
                                                $("#testdelete").html(data)}'), //trả kết quả về thẻ div id=test
                                                array('confirm'=>'Bạn có muốn xóa đăng kí không !!! ',) //Nếu bạn muốn thông báo
                        );
                    ?>
                    <?php $this->endWidget(); ?>
                    <?php } // end if ?>
                </div>
            </div>
            <div class="clr"></div>
        </div>
        <div class="clr"></div>
        <div class="mod">
            <div>
            <?php
                $this->widget('CTabView', array(
                'tabs'=>array(
                    'tab1'=>array(
                        'title'=>'Danh sách đấu giá',
                    ),
                    'tab2'=>array(
                        'title'=>'Bình luận',
                        //'view'=>'viewjob',
                        //'data'=>array('logs'=>$logs),
                    ),
                ),
                'cssFile'=>false,
                'htmlOptions'=>array('class'=>'dndTab')));
            ?>
            </div>
        <!--SO NGUOI THAM GIA-->
            <div><?php $this->widget('service.components.All_Bid');?></div>
        </div>
        <div class="clr"></div>
        <?php 
            $type_j= null;
            $type_s= 1;
            $this->widget('application.components.CommentWidget',array('comment'=>$comment,'id'=>$model->id, 'type_s'=>$type_s)); 
        ?>
    </div>
       
    <div class="col-3 row">
        <div class="mod">
            <div class="mod-tit"><a href="#">Dịch vụ</a></div>
            <div class="mod-cont more-pro">
                <!--<ul>
                        <li ><a href="#">Danh sách đăng kí seminar,</a></li>
                        <li  ><a href="#">Danh sách đăng kí bảo vệ</a></li>
                        <li ><a href="#">Danh sách thầy hướng dẫn</a></li>
                        <li  ><a href="#">Danh sách học viên chưa nộp đề cương</a></li>
                        <li ><a href="#">Danh sách chưa duyệt đề cương</a></li>
                        <li  ><a href="#">Danh sách xyz</a></li>
                </ul>-->
                <div class="post-button">
                    <a href="index.php?r=service/create/">
                    <input class="orange" type="button" value="Đăng dịch vụ mới" />
                    </a>
                </div>    
            </div>
            <div class="clr"></div>
           </div>
        <div class="clr"></div>
    </div>
       
    <div class="col-3 row">
        <div class="mod">
            <div class="mod-tit"><a href="#">Dự án tương tự</a></div>
                   <!--Dự án tương tự-->
            <?php $this->widget('service.components.Equal_Service');?>
            <div class="clr"></div>
        </div>
        <div class="clr"></div>
    </div>
   
    <div class="col-3 row">
        <div class="mod">
            <div class="mod-tit"><a href="#">Tag dịch vụ</a></div>
            <div class="mod-cont more-pro">
            <h4>
                <?php $this->widget('TagCloud', array(
                    'maxTags'=>20,
                )); ?>
            </h4>
            </div>
            <div class="clr"></div>
        </div>
        <div class="clr"></div>
    </div>
</div>

 
   
    <div class="clr"></div>
    <div class="clr"></div>
    <div class="clr"></div>
<!-- end body -->

<!-- -->
<!--   footer    -->
<script>
    function get_get()
    {
        return true;
    }
    $("#button_edit").click(function(){
        var elem = document.getElementById("content_mota"); // id cua noi dung ban dau
        var form = document.getElementById("edt_mota"); // id cua edit
        $('#button_edit').css("display","none");

        //$('#content_mota').css("display","block");
        if (elem.style.display == "block")
        {
            elem.style.display = "none";
            form.style.display = "block";
        }
        else
        {
            elem.style.display = "block";
            form.style.display = "none";
        }
    });
    $("#button_dang").click(function(){
        var elem = document.getElementById("content_mota"); // id cua noi dung ban dau
        var form = document.getElementById("edt_mota"); // id cua edit
        $('#button_edit').css("display","block");

        if (elem.style.display == "block")
        {
            elem.style.display = "none";
            form.style.display = "block";

        }
        else
        {
            elem.style.display = "block";
            form.style.display = "none";

        }
    });
</script>
